<script>
window.w = new Worker('worker.js');
window.w.addEventListener('message', e => {
  console.error(e.data);
  if (e.data === 'pause')
    debugger;
});
window.w.postMessage({foo: { bar: 'to worker'}});
window.isWorker = false;

</script>
